<extend name="Index:info"/>

<block name="body">

<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>增加内容</strong></div>
  <div class="body-content">
    <form method="post" class="form-x" action="" enctype="multipart/form-data">
      <div class="form-group">
        <div class="label">
          <label>标题：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="news_title" data-validate="required:请输入标题" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>分类：</label>
        </div>
        <div class="field">
          <select name="category_id" class="input w50">
            <option value="0">无分类</option>
            <volist name="category" id="val">
              <option value="{$val.id}">{$val.category_name}</option>
            </volist>

          </select>

          <div class="tips"></div>
        </div>
      </div>
      <if condition="$iscid eq 1">
        <div class="form-group">
          <div class="label">
            <label>分类标题：</label>
          </div>
          <div class="field">
            <select name="category_id" class="input w50">
              <option value="0">请选择分类</option>
              <option value="1">项目赛事</option>
              <option value="2">产品分类</option>
              <option value="3">产品分类</option>
              <option value="4">产品分类</option>
            </select>
            <div class="tips"></div>
          </div>
        </div>
        <div class="form-group">
          <div class="label">
            <label>其他属性：</label>
          </div>
          <div class="field" style="padding-top:8px;"> 
            首页 <input id="ishome"  type="checkbox" />
            推荐 <input id="isvouch"  type="checkbox" />
            置顶 <input id="istop"  type="checkbox" /> 
         
          </div>
        </div>
      </if>
      <div class="form-group">
        <div class="label">
          <label>描述：</label>
        </div>
        <div class="field">
          <textarea class="input" name="note" style=" height:90px;"></textarea>
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>内容：</label>
        </div>
        <div class="field">
          <textarea name="news_content" class="input" style="height:450px; border:1px solid #ddd;"></textarea>
          <div class="tips"></div>
        </div>
      </div>
     
      <div class="clear"></div>
      <div class="form-group">
        <div class="label">
          <label>关键字：</label>
        </div>
        <div class="field">
          <input type="text" class="input" name="keywords" value=""/>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>排序：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" name="sort" value=""  data-validate="number:排序必须为数字" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group form-img">
        <div class="label">
          <label>图片：</label>
        </div>
        <div style="margin :0px auto; width:990px;">
          <input type="file"  name="img_url[]" id="doc" multiple="multiple"  style="width:150px;" onchange="javascript:setImagePreviews();" accept="image/*" />
          <div id="dd" style=" width:990px;"></div>
        </div>
        <!--
        <div class="field">
          <input type="file" id="url1" name="img_url" class="input tips" style="width:25%; float:left;"  value=""  data-toggle="hover" data-place="right" data-image="" />
           <input type="button" class="button bg-blue margin-left" id="image1" value="+ 浏览上传"  style="float:left;">
           <div class="tipss">图片尺寸：500*500</div>

        </div>-->
      </div>
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>
  <script type="text/javascript">

    //下面用于多图片上传预览功能

    function setImagePreviews(avalue) {

      var docObj = document.getElementById("doc");

      var dd = document.getElementById("dd");

      dd.innerHTML = "";

      var fileList = docObj.files;

      for (var i = 0; i < fileList.length; i++) {

        dd.innerHTML += "<div style='float:left' > <img id='img" + i + "'  /> </div>";
        var imgObjPreview = document.getElementById("img"+i);
        if (docObj.files && docObj.files[i]) {
          //火狐下，直接设img属性

          imgObjPreview.style.display = 'block';

          imgObjPreview.style.width = '150px';

          imgObjPreview.style.height = '100px';

          //imgObjPreview.src = docObj.files[0].getAsDataURL();
          //火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
          imgObjPreview.src = window.URL.createObjectURL(docObj.files[i]);
        } else {
          //IE下，使用滤镜
          docObj.select();
          var imgSrc = document.selection.createRange().text;
          alert(imgSrc)
          var localImagId = document.getElementById("img" + i);

          //必须设置初始大小

          localImagId.style.width = "150px";

          localImagId.style.height = "100px";

          //图片异常的捕捉，防止用户修改后缀来伪造图片
          try {
            localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
            localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
          }
          catch (e) {
            alert("您上传的图片格式不正确，请重新选择!");
            return false;
          }
          imgObjPreview.style.display = 'none';
          document.selection.empty();
        }
      }
      return true;
    }
  </script>
</block>